package dao.impl;

import java.io.Serializable;

import org.hibernate.LockMode;
import org.hibernate.Session;
import util.HibernateSessionFactory;

public abstract class BaseDaoHibernateImpl {

	protected Session getSession() {
		return HibernateSessionFactory.getSession();
	}

	@SuppressWarnings("unchecked")
	public Object findById(Class entityClass, Serializable id, boolean lock) {
		Object object;
		if (lock)
			object = getSession().get(entityClass, id, LockMode.UPGRADE);
		else
			object = getSession().get(entityClass, id);
		return object;
	}
}